<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <title>会议视频添加</title>
    <?php PrintPageHead(); ?>
    <link href="../resource/css/hermes.css" rel="stylesheet">
    <link href="../resource/js/calendar/calendar-blue.css" type="text/css" rel="stylesheet">
    <script src="../resource/js/calendar/calendar.js" type="text/javascript"></script>
    <script src="../resource/js/hermes.js"></script>
    <style type="text/css">
       .form_d{
           width:500px;
           margin: 20px auto;
       }
    </style>
    <?php
    if (!array_key_exists("公众号ID",$_SESSION)) {
        header("Location:back.php");
    }
    $bm=new C后台管理员();

    $课程id ='';
    if(isset($_REQUEST['id']))$课程id = $_REQUEST['id'];

    if($课程id){
        $内容=pdo()->selectOne("SELECT a.*,b.id yid ,b.name name  FROM `会议视频` a LEFT JOIN `用户` b ON(a.`操作人id` =b.id)    where a.id=".$_REQUEST['id'].";");

    }
$sql="select id,父id,name  from 会议表";
    $res=pdo()->selectAll($sql);
    ?>
</head>
<body>

<!-- 配置文件 -->
<script type="text/javascript" src="../ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="../ueditor/ueditor.all.min.js"></script>
<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container', {
        toolbars: [
            [ 'fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|','link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'simpleupload', 'insertimage', 'emotion', 'scrawl', 'attachment', 'map', 'gmap', 'insertframe']
        ],
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
</script>

<div class="container-fluid">
    <?php include_once 'back_header.php'; ?>
    <div class="panel panel-primary">
        <div class="panel-heading text-center"><h3 class="panel-title"><?php if(isset($内容))echo "编辑";else echo "添加";?>会议视频课程</h3></div>
        <div class="form_d">
            <form action="" method="post">
                您的姓名:<input type="text" name="name" id="namese" style="width: 120px">
                <input type="button" onclick="selectshow()" name="select" value="搜索用户">

            </form>
        </div>
        <div class="form_d"><span style="width: 180px">用   户:</span>
            <div id="xianshi">
                <?php  if($内容){?>
                    <input type="radio" checked="checked" value="<?=$内容['操作人id']?>" name="专家id">
                    <?=$内容['name']?>
                <?php  }?>
            </div>


        <form action="" method="post">
            <div class="form_d">
                <input type="hidden" value="<?=$内容['操作人id']?>" id="autor" name="操作人id">
                <input type="hidden" value="<?=$内容['群id']?>" id="autor" name="群id">
                <input name="id" value="<?=@$内容['id']?>" type="hidden">
                <div class="form_d"><span>会议名称:</span><select name="会议名称">
                        <option>请选择</option>
                        <?php foreach ($res as $k => $b){
                          if($内容['会议名称']==$b['id']){?>
                           <option  selected value="<?=$b['父id']?>-<?=$b['id']?>"><?=$b['name']?></option></option>
                      <?php }else{?>
                       <option value="<?=$b['父id']?>-<?=$b['id']?>"><?=$b['name']?></option></option>
                   <?php   }?>

                       <?php  } ?>
                        </select></div>
                <div class="form_d"><span>标题:</span><input style="width: 80%;" type="text" name="title" value="<?=@$内容['title']?>"></div>
            <div class="form_d"><span>视频路径:</span><textarea style="width: 80%;" type="text" name="url" value=""><?=@$内容['url']?></textarea></div>
                <div class="form_d"><span>主讲人:</span><input style="width: 80%;" type="text" name="主讲人" value="<?=@$内容['主讲人']?>"></div>
                <div class="form_d"><span>视频播放时长:</span><!-- 加载编辑器的容器 -->
                    <input type="text"  name="播放时长" value="<?=@$内容['播放时长']?>"/>
                </div>
                <div class="form_d"><span>预期视频上线时间:</span><!-- 加载编辑器的容器 -->
                    <input type="date"  name="nowtime" placeholder="2016-5-10" value="<?=@$内容['nowtime']?>"/>
                </div>



            <div class="form_d"><input id="tijiao" type="submit" name="okn" value="提交">

                <a href="../back.php?state=back14meet_shipin_list">查看历史</a> </div>

        </form>

</div>
    </div>

</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>

</body>
</html>
<script src="../resource/js/jquery-1.11.1.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../resource/js/bootstrap.min.js"></script>
<script language="JavaScript">
    function selectshow(){
        var name= document.getElementById("namese").value;
        $.post('back.php?state=BackSellerAjax',{name:name,'businessFlag':'ac查找用户'},function(data) {
            document.getElementById('xianshi').innerHTML='';
            document.getElementById("xianshi").innerHTML=data;

        });

    }
    $(function(){
//    $("#fasong").click(function(){
//        $(this).attr('hidden',true);
//    });
//    $("#fasong2").click(function(){
//        $(this).attr('hidden',true);
//    });


        $("#tijiao").click(function(){
            var q= $('input[name="专家id"]:checked').val();
            $('#autor').val(q);
            $(this).attr('hidden',true);
        });
    })

</script>


<?php

if(isset($_POST['okn'])){
    unset($_REQUEST['okn']);
    unset($_REQUEST['state']);
    if($_REQUEST['title']==''||$_REQUEST['url']==''){
        echo "<script>alert('请认真填写信息!');</script>";
    }else{
        $a=array();
        $a=explode('-',$_REQUEST['会议名称']);
        $_REQUEST['会议名称']=$a[1];
         if($内容){
                $dos= new  Do会议视频();
                $res1 =pdo()->update($dos->tableName(),$_REQUEST,array("id"=>$_REQUEST['id']));
                if($res1){
                    echo "<script>alert('修改成功');location.replace(location.href);</script>";
                }else{

                    echo "<script>alert('修改失败或没有修改任何信息');</script>";
                }
            }else{
                unset($_REQUEST['id']);
                $dos= new  Do会议视频();
             $用户openID = pdo()->selectOne("select openID from 用户 WHERE id=".$_REQUEST['操作人id']);
                $b=new CUI数据中心('Seller17Shipin_Lessons',$用户openID['openID']);
                $c用户 = new C用户($b->vo信息中心);

               $群id = $c用户->fc创建课程群组($_REQUEST['操作人id'],$a[0]);
                $_REQUEST['群id']=$群id;
                $res=pdo()->insert($dos->tableName(),$_REQUEST);
              if( $res){

                    echo "<script language='javascript'>alert('添加成功!');location.replace('back.php?state=back14meet_shipin_list');</script>";

                }else{

                    echo "<script>alert('添加失败');</script>";
                }
             }



    }

}
?>
